package com.hspedu.static_;

import java.util.Scanner;

public class StaticMethod {
    public static void main(String[] args) {

        Stu tom = new Stu("tom");
        tom.payFee(100);

        Stu mary = new Stu("mary");
        mary.payFee(200);

        //输出当前收到的总学费
        Stu.showFee();

    }
}


class Stu {

    //属性
    private String name;

    //类变量
    private static double fee = 0;

    public Stu(String name) {
        this.name = name;
    }

    //类方法：可以访问类变量
    public static void payFee(double fee) {
        Stu.fee += fee;
    }

    public static void showFee() {
        System.out.println("总学费有：" + Stu.fee);
    }
}